/*!
    \copyright  Copyright (c)  2024 Qualcomm Technologies International, Ltd.\n
                All Rights Reserved.\n
                Qualcomm Technologies International, Ltd. Confidential and Proprietary.
    \defgroup   gatt_server_gap GATT GAP Server
    @{
    \ingroup    gatt_servers_domain
    \brief      Header file for the GAP Server module config.
*/

#ifndef GATT_SERVER_GAP_CONFIG_H_
#define GATT_SERVER_GAP_CONFIG_H_

#include <bt_types.h>

typedef struct
{
    bool        legacy_device_support;
    bool        include_appearance;
} gap_server_gap_config_t;

#ifdef FEATURE_GATT_SERVER_GAP_OPTION_LEGACY_DEVICE_SUPPORT
#define LEGACY_DEVICE_SUPPORT   FEATURE_GATT_SERVER_GAP_OPTION_LEGACY_DEVICE_SUPPORT
#else
#define LEGACY_DEVICE_SUPPORT   1
#endif

#ifdef FEATURE_GATT_SERVER_GAP_OPTION_INCLUDE_APPEARANCE
#define INCLUDE_APPEARANCE      FEATURE_GATT_SERVER_GAP_OPTION_INCLUDE_APPEARANCE
#else
#ifdef INCLUDE_LE_AUDIO_UNICAST
#define INCLUDE_APPEARANCE      1
#else
#define INCLUDE_APPEARANCE      0
#endif
#endif

#define RESERVED_DATA_LENGTH            5   // 2 byte header + 3 bytes for flags
#define MAX_LEGACY_PAYLOAD_LENGTH       31
#define MAX_EXTENDED_PAYLOAD_LENGTH     254

#ifdef FEATURE_GATT_SERVER_GAP_OPTION_ADVERTISED_NAME_MAX_LENGTH
#define GAP_ADVERT_NAME_MAX_LENGTH  FEATURE_GATT_SERVER_GAP_OPTION_ADVERTISED_NAME_MAX_LENGTH
#else
#if LEGACY_DEVICE_SUPPORT 
#define GAP_ADVERT_NAME_MAX_LENGTH (MAX_LEGACY_PAYLOAD_LENGTH - RESERVED_DATA_LENGTH)
#else
#define GAP_ADVERT_NAME_MAX_LENGTH (MAX_EXTENDED_PAYLOAD_LENGTH - RESERVED_DATA_LENGTH)
#endif
#endif

/*! \brief Gets the GATT Server GAP config.

    \returns the current GATT Server GAP config
*/
gap_server_gap_config_t * GattServerGap_GetConfig(void);

/*! \brief Sets the GATT Server GAP config.

    \param config The new GATT Server GAP config
*/
void GattServerGap_SetConfig(gap_server_gap_config_t * config);

#endif